home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4645 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: beach.and.nl!usenet
  2. From: jos@and.nl (Jos A. Horsmeier)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Logical exclusive-or
  5. Date: 6 Feb 1996 09:15:52 GMT
  6. Organization: AND Operations Research B.V.
  7. Message-ID: <4f7688$4te@beach.and.nl>
  8. References: <4f6lrq$bcr@lastactionhero.rs.itd.umich.edu>
  9. NNTP-Posting-Host: klepzeiker.and.nl
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=ISO-8859-1
  12. X-Newsreader: WinVN 0.99.5
  13.  
  14. In article <4f6lrq$bcr@lastactionhero.rs.itd.umich.edu>, davidm@umich.edu 
  15. wrote:
  16.  
  17. |Is there a good reason why C doesn't have a logical exclusive-or
  18. |operator?  A look at the precedence hierarchy suggests an obvious
  19. |symbol and precedence for such an operator:
  20. |
  21. |        bitwise and             &
  22. |        bitwise exclusive or    ^
  23. |        bitwise inclusive or    |
  24. |        logical and             &&
  25. |        logical or              ||
  26. |
  27. |The logical exclusive or would be represented by ^^ and have
  28. |precedence higher than || but lower than && .  If C requires machines
  29. |to be able to implement bitwise XOR, then it would seem reasonable to
  30. |require the logical operator also.
  31.  
  32. Note that although the logical 'and' and 'or' operators do not 
  33. evaluate their right operand if their left operand is false or
  34. true resepectively, the 'logical exclusive or' operator must
  35. evaluate both operands no matter what the value of the left hand
  36. operand is. So the sole purpose of a '^^' operator would be a lexical
  37. shorthand for: 
  38.  
  39.     a ^^ b == (!(a) != !(b)) 
  40.  
  41. That wouldn't be much of added functionality, would it?
  42.  
  43. kind regards,
  44.  
  45. Jos aka jos@and.nl
  46. -- 
  47. Atnwgqkrl gy zit vgksr, ug qshiqwtzoeqs!
  48.  
  49.